<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>genarray</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="gbuzz.html" title="gbuzz" />
    <link rel="next" href="genarray_i.html" title="genarray_i" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">genarray</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="gbuzz.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="genarray_i.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="genarray"></a>
      <div class="titlepage"></div>
      <a id="IndexGenarray" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">genarray</span>
        </h2>
        <p>genarray — 
      Generate a vector with an arithmetic sequence.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp112577888"></a>
        <h2>Description</h2>
        <p>
      Generate a vector (one-dimensional k-rate or i-rate array) with an arithmetic sequence.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp112620384"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">karray <span class="command"><strong>genarray</strong></span> kstart, kens[, inc]</pre>
        <pre class="synopsis">iarray <span class="command"><strong>genarray</strong></span> istart, iens[, inc]</pre>
      </div>
      <div class="refsect1">
        <a id="idp112623968"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>istart</em></span> -- value to place in first element.
    </p>
        <p>
      <span class="emphasis"><em>iend</em></span> -- last value to place in array.
    </p>
        <p>
      <span class="emphasis"><em>inc</em></span> -- amount to add to previous value
      (default 1).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp112627424"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the genarray opcode. It uses the file <a class="ulink" href="examples/genarray.csd" target="_top"><em class="citetitle">genarray.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp112629280"></a>
          <p class="title">
            <strong>Example 347. Example of the genarray opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-n
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1

<span class="comment">;create and fill two arrays</span>
iArr1[] <span class="opc">genarray</span> 1, 6
iArr2[] <span class="opc">genarray</span> 1, 6, 2<span class="op">/</span>3

<span class="comment">;print the content of iArr1</span>
        <span class="opc">printf</span>  "<span class="op">%</span>s", 1, "iArr1<span class="op">:</span> start<span class="op">=</span>1, end<span class="op">=</span>6, step<span class="op">=</span>default\n"
kndx    <span class="op">=</span>       0
  until kndx <span class="op">==</span> <span class="opc">lenarray</span>(iArr1) do
        <span class="opc">printf</span>  "iArr[<span class="op">%</span>d] <span class="op">=</span> <span class="op">%</span>f\n", kndx<span class="op">+</span>1, kndx, iArr1[kndx]
kndx    <span class="op">+</span><span class="op">=</span>      1
  od

<span class="comment">;print the content of iArr2</span>
        <span class="opc">printf</span>  "<span class="op">%</span>s", 1, "iArr2<span class="op">:</span> start<span class="op">=</span>1, end<span class="op">=</span>6, step<span class="op">=</span>2<span class="op">/</span>3\n"
kndx    <span class="op">=</span>       0
  until kndx <span class="op">==</span> <span class="opc">lenarray</span>(iArr2) do
        <span class="opc">printf</span>  "iArr[<span class="op">%</span>d] <span class="op">=</span> <span class="op">%</span>f\n", kndx<span class="op">+</span>1, kndx, iArr2[kndx]
kndx    <span class="op">+</span><span class="op">=</span>      1
  od

        <span class="opc">turnoff</span>
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> 1 0 1
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp112633568"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="vectorial.html" title="Vectorial Opcodes"><em class="citetitle"></em>Vectorial opcodes</a>
</p>
      </div>
      <div class="refsect1">
        <a id="idp112635616"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: John ffitch</td>
          </tr>
          <tr>
            <td>Codemist Ltd</td>
          </tr>
          <tr>
            <td>2013</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 6.00</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="gbuzz.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="genarray_i.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">gbuzz </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> genarray_i</td>
        </tr>
      </table>
    </div>
  </body>
</html>
